package com.pamper.config;

/**
 * @program: pamper
 * @description: 递归添加文件gitkeep,为了提交空文件夹啊
 * @author: Mrs.Lin
 * @create 2019-09-09 20:59
 **/
import java.io.File;
import java.io.IOException;

public class Git {
    public static void main(String[] args) {
        File fileTree = new File("D:\\pamper");
        deepSearch(fileTree);
    }


    public static void deepSearch(File file) {
        if (!file.isDirectory()) {
            return;
        }
        File[] fileList = file.listFiles();
        if(fileList.length>0){
            for (File temp : fileList) {
                if(temp.isDirectory()){
                    deepSearch(temp);
                }
            }
        }else{
            addGit(file);
        }

    }


    public static void addGit(File file){
        File gitkeep = new File(file.getAbsolutePath()+File.separator+".gitkeep");
        try {
            gitkeep.createNewFile();
            System.out.println("在"+file.getAbsolutePath()+"下创建gitkeep");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

